//*****************************************************************************
//
// File Name	: 'pb8515tiny.h'
// Title		: Board io initialization functions
// Author		: Sami Kukkonen - Copyright (C) 2011
// Created		: 22.6.2011
// Target MCU	: AT90S8515
// Editor Tabs	: 4
//
// This code is distributed under the GNU Public License
//		which can be found at http://www.gnu.org/licenses/gpl.txt
//
//*****************************************************************************

#ifndef PB8515TINY_H
#define PB8515TINY_H

#include <avr/io.h>

// 8MHz crystal onboard
#define F_CPU 8000000UL

// Piezo port and data direction register
#define PB_PZ_PORT		PORTB
#define PB_PZ_DDR		DDRB
#define PB_PZ_PIN		4
// SW1 & SW2 port and data direction register
#define PB_SW12_PORT	PORTD
#define PB_SW12_DDR		DDRD
#define PB_SW12_PINX	PIND
#define PB_SW1_PIN		2
#define PB_SW2_PIN		3
// SW3 & SW4 port and data direction register
#define PB_SW34_PORT	PORTB
#define PB_SW34_DDR		DDRB
#define PB_SW34_PINX	PINB
#define PB_SW3_PIN		0
#define PB_SW4_PIN		1

// Switch access macros
#define PB_SW_1 (!PB_SW12_PINX & _BV(PB_SW1_PIN))
#define PB_SW_2 (!PB_SW12_PINX & _BV(PB_SW2_PIN))
#define PB_SW_3 (!PB_SW34_PINX & _BV(PB_SW3_PIN))
#define PB_SW_4 (!PB_SW34_PINX & _BV(PB_SW4_PIN))

// Initializes the I/O ports on AT90S8515 to work with
// pb8515tiny switches, leds and piezo
void pbInit(void);

#endif
